function CustomToString(target: Function) {
  target.prototype.toString = function() {
    return JSON.stringify(this)
  }
  Object.seal(target.prototype) // 将对象原型封锁，属性不允许随意的添加删除
}

@CustomToString
class Person {
  public name: string
  public age: number
  constructor(name: string, age: number) {
    this.name = name
    this.age = age
  }
}

const p1 = new Person('张三', 18)
// console.log(p1.toString())  // [object Object]
// console.log(JSON.stringify(p1))  // {"name":"张三","age":18}
console.log(p1.toString())

// @ts-ignore //忽略 TS 检查
interface Person {
  x:number 
}
Person.prototype.x = 99